package factory;

import java.sql.SQLException;
import java.util.ArrayList;

import processes.CuttingMachine;
import processes.CuttingMachineManager;
import processes.DyeingMachine;
import processes.DyeingMachineManager;
import processes.Machine;
import processes.MachineManager;
import processes.PressingMachine;
import processes.PressingMachineManager;
import processes.SewingMachine;
import processes.SewingMachineManager;
import processes.TestingMachine;
import processes.TestingMachineManager;
import processes.WrappingMachine;
import processes.WrappingMachineManager;

public class FactoryInitailizer{
	public FactoryInitailizer() {
		factoryInitialize();
	}
	
	public void factoryInitialize(){
		ArrayList<Machine> machineList = new ArrayList();
		MachineManager tempMachineManager = null;
		Machine tempMachine = null;
		ObserverManager observerManager = ObserverManager.getInstance();
		
		//cuttingMachines
		tempMachineManager = new CuttingMachineManager();
		tempMachineManager.addMachine(new CuttingMachine(tempMachineManager, "C1"));
		tempMachineManager.addMachine(new CuttingMachine(tempMachineManager, "C2"));
		observerManager.addMachineManager(tempMachineManager);
		
		//sewingMachines
		tempMachineManager = new SewingMachineManager();
		tempMachineManager.addMachine(new SewingMachine(tempMachineManager, "S1"));
		tempMachineManager.addMachine(new SewingMachine(tempMachineManager, "S2"));
		tempMachineManager.addMachine(new SewingMachine(tempMachineManager, "S3"));
		tempMachineManager.addMachine(new SewingMachine(tempMachineManager, "S4"));
		observerManager.addMachineManager(tempMachineManager);

		//dyeingMachines
		tempMachineManager = new DyeingMachineManager();
		tempMachineManager.addMachine(new DyeingMachine(tempMachineManager, "D1"));
		tempMachineManager.addMachine(new DyeingMachine(tempMachineManager, "D2"));
		tempMachineManager.addMachine(new DyeingMachine(tempMachineManager, "D3"));
		observerManager.addMachineManager(tempMachineManager);

		//pressingMachines
		tempMachineManager = new PressingMachineManager();
		tempMachineManager.addMachine(new PressingMachine(tempMachineManager, "P1"));
		observerManager.addMachineManager(tempMachineManager);

		//testingMachines
		tempMachineManager = new TestingMachineManager();
		tempMachineManager.addMachine(new TestingMachine(tempMachineManager, "T1"));
		tempMachineManager.addMachine(new TestingMachine(tempMachineManager, "T2"));
		tempMachineManager.addMachine(new TestingMachine(tempMachineManager, "T3"));
		tempMachineManager.addMachine(new TestingMachine(tempMachineManager, "T4"));
		tempMachineManager.addMachine(new TestingMachine(tempMachineManager, "T5"));
		observerManager.addMachineManager(tempMachineManager);

		//wrappingMachines
		tempMachineManager = new WrappingMachineManager();
		tempMachineManager.addMachine(new WrappingMachine(tempMachineManager, "W1"));
		tempMachineManager.addMachine(new WrappingMachine(tempMachineManager, "W2"));
		observerManager.addMachineManager(tempMachineManager);

		try {
			Thread.sleep(1000);
			new Generator();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
